// useRef获取dom引用
import { useRef } from "react";
import { useWinSize } from "./hooks/useWinSize";
import { useCounter } from "./hooks/useCouter";
import { useGoTop } from "./hooks/useGoTop";
function App() {
  const pref = useRef();
  const iref = useRef();
  const size = useWinSize();
  const [counter,stop] = useCounter(5);
  const elem = useGoTop()
  const elem2 = useGoTop();
  return ( <div>
    <button onClick={stop}>{counter}</button>
    <p>w:{size.w},h:{size.h}</p>
    <p ref={pref}>你好我是useRef</p>
    <input ref={iref}/><br/>
    <button onClick={()=>alert(pref.current.innerText)}>获取p内容</button>
    <button onClick={()=>alert(iref.current.value)}>获取表单值</button>
    <button 
    ref={elem}
    style={{position:"fixed",right:"20px",bottom:"50px"}}>top</button>
    <p style={{height:"3000px"}}>我可爱</p>
    <p ref={elem2}>bottom</p>
  </div> );
}

export default App;